
<template>
  <views class="agent_account_withdraw">
    <viewTitle :title="'账户详情'" :border="false"></viewTitle>
    <!-- 搜索栏  企业端-代理商端-服务商端 -->
    <div class="search flex flexC">
      <!-- 所属服务商-银行流水号-客户编号-记录类型 -->
      <el-form ref="form" label-width="auto" :inline="true">
        <div class="search_input flex flexR center">
          <div class="customer_number flex flexR center">
            <el-form-item label="业务订单号:">
              <el-input v-model="form.order_number" placeholder="请输入客户名称" :clearable="true"></el-input>
            </el-form-item>
          </div>
          <div class="bank_statement flex flexR center">
            <el-form-item label="客户名称:">
              <el-input v-model="form.customer_name" placeholder="请输入客户名称" :clearable="true"></el-input>
            </el-form-item>
          </div>
          <div class="their_facilitator flex flexR center">
            <el-form-item label="客户编号:">
              <el-input v-model="form.customer_number" placeholder="请输入业务订单号" :clearable="true"></el-input>
            </el-form-item>
          </div>
          <div class="record_type flex flexR center">
            <el-form-item label="状态:">
              <el-select v-model="form.pay_state" clearable placeholder="全部">
                <el-option
                  v-for="item in form.pay_state_list"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </div>
        </div>
      </el-form>
      <!-- 充值时间  按钮 (查询、重置、导出列表、录单)-->
      <el-form ref="form" label-width="auto" :inline="true">
        <div class="pay_btn flex">
          <!-- 充值时间 -->
          <div class="pay_time flex flexR center">
            <el-form-item label="提现时间:">
              <el-date-picker
                v-model="form.pay_time"
                type="datetimerange"
                align="right"
                :default-time="['0:00:00','23:59:59']"
                unlink-panels
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :picker-options="pickerOptions"
                @change="changeTime"
              ></el-date-picker>
            </el-form-item>
          </div>
          <!-- 按钮（查询、重置、导出列表）  -->
          <el-form-item>
            <div class="flex flexR pay_btn_list">
              <el-button type="primary" @click="getData" icon="el-icon-search">查询</el-button>
              <el-button @click="reset">重置</el-button>
              <el-button type="danger" @click="exportExcel" icon="el-icon-download">导出列表</el-button>
              <!-- <el-button type="success" >录单</el-button> -->
            </div>
          </el-form-item>
        </div>
      </el-form>
    </div>
    <!-- 展示列表 -->
    <div class="table_list">
      <el-table
        border
        :data="tableData"
        style="width: 100%;max-width:none;"
        :header-cell-style="getRowClass"
        :select-on-indeterminate="true"
        :fit="true"
        :lazy="true"
        @row-click="clickRow"
        max-height="450"
      >
        <el-table-column fixed type="index" label="序号" width="100"></el-table-column>
        <el-table-column fixed prop="agent_sn" label="客户编号" width="120"></el-table-column>
        <el-table-column prop="agent_name" label="客户名称" width="120"></el-table-column>
        <el-table-column prop="agent_withdraw_log_sn" label="业务订单号" width="300"></el-table-column>
        <el-table-column prop="money" label="申请金额" width="120"></el-table-column>
        <el-table-column prop="type" label="业务类型" width="120"></el-table-column>
        <el-table-column prop="bank_account" label="银行账户" width="200"></el-table-column>
        <el-table-column prop="bank_code" label="银行账号" width="200"></el-table-column>
        <el-table-column prop="check_time" label="审批时间" width="200"></el-table-column>
        <el-table-column prop="created_time" label="申请时间" width="200"></el-table-column>
        <el-table-column prop="status_desc" label="状态" width="150"></el-table-column>
      </el-table>
      <div class="flex flexR paging">
        <el-pagination
          style="background:#fff; padding:10px 0"
          background
          layout="total, sizes,prev, pager, next, jumper"
          @size-change="(page_size) => {this.pagination.page_size = page_size;this.getData()}"
          @current-change="(page_size) => {this.pagination.page_start = page_size;this.getData()}"
          :page-sizes="[10, 20, 30, 50]"
          :page-size="pagination.page_size"
          :total="pagination.total_count"
          :current-page="pagination.current_page"
          :page-count="pagination.page_count"
        ></el-pagination>
      </div>
    </div>
  </views>
</template>



<script>
export default {
  data() {
    return {
      //  三段综合  企业端  代理商端  服务商端
      download_url: "",
      pagination: {
        page_start: 0, //搜索开始页码
        current_page: 0, //当前页码
        page_count: 0, //总页数
        page_size: 10, //每页数量
        total_count: 0 //总数量
      },
      form: {
        bank_statement: "", //  银行流水
        their_facilitator: "", //  所属服务商
        pay_state: "", //  充值状态
        customer_number: "", //  客户编号
        customer_name: "", //  客户名称
        order_number: "", //  业务单号
        from_time: "", //  提现时间
        end_time: "" //  提现时间
      },
      tableData: [],
      pay_time: "", //  提现时间
      pay_state_list: [
        { value: "", label: "全部" },
        { value: "0", label: "申请中" },
        { value: "1", label: "申请通过" },
        { value: "2", label: "不通过" }
      ], //  充值状态列表
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            }
          }
        ]
      }
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    //    修改第一行样式
    getRowClass({ row, column, rowIndex, columnIndex }) {
      if (rowIndex === 0) {
        return "background: #FAFAFA ";
      } else {
        return "";
      }
    },
    //     点击单行
    clickRow(row, column, event) {
      console.log(row, column, event);
    },
    //    修改是否换行
    changeStyleRow(width) {
      let _width = width - 290 - 350 - 300 - 50 - 25;
      if (_width > 300) {
        this.marginLeft = 25;
      } else {
        this.marginLeft = 0;
      }
    },
    //  搜索/查询
    getData() {
      let { code, msg, data } = this.$api.sendSync(
        this.$mapapi.awithdrawLog,
        this.form
      );
      if (code != 200 && code != 501) {
        this.tableData = [];
        this.$message.error(msg);
        return;
      }
      this.download_url = data.download_url;
      this.tableData = data.list;
      this.pagination = data.pagination;
    },
    //  重置
    reset() {
      this.form.bank_statement = ""; //  银行流水
      this.form.their_facilitator = ""; //  所属服务商
      this.form.pay_state = ""; //  充值状态
      this.form.customer_number = ""; //  客户编号
      this.form.customer_name = ""; //  客户名称
      this.form.order_number = ""; //  业务单号
      this.form.pay_time = ""; //  提现时间
    },
    //导出
    exportExcel() {
      //console.log('downurl',this.data)
      window.open(this.download_url);
    },
    //时间转换
    changeTime() {
      console.log("this.form.pay_time", this.form.pay_time);
      if (this.form.pay_time) {
        this.form.from_time = this.form.pay_time[0]/1000;
        this.form.end_time = this.form.pay_time[1]/1000;
      } else {
        this.form.from_time = "";
        this.form.end_time = "";
      }
    }
  },
  created() {}
};
</script>


<style lang="less" :scope="true"  src="@/style/account/agent_account_withdraw.less" >
</style>